# -*- coding: utf-8 -*-
"""
Flask扩展模块
统一管理所有Flask扩展实例
"""

from flask_sqlalchemy import SQLAlchemy
from flask_jwt_extended import JWTManager
from flask_cors import CORS
from flasgger import Swagger

# 初始化扩展实例
db = SQLAlchemy()
jwt = JWTManager()

# 配置CORS - 允许所有来源和方法
cors = CORS(
    resources={
        r"/api/*": {
            "origins": "*",
            "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
            "allow_headers": ["Origin", "X-Requested-With", "Content-Type", "Accept", "Authorization"],
            "expose_headers": ["Content-Range", "X-Content-Range"],
            "supports_credentials": False
        }
    }
)

swagger = Swagger()

__all__ = ['db', 'jwt', 'cors', 'swagger']
